import {
	PanelViewActionType,
	IPanelViewAbility,
	IPanelViewController,
	IPanelViewControllerParams,
	IPanelViewModel,
	IPanelViewStore,
	IParam,
	IViewEvent,
} from '@/core';
import { QXEvent } from 'qx-util';
import {
	getViewClassNames,
	useViewAction,
	useViewBasic,
	useViewControllerParams,
	useViewProps,
} from '../use-view';

/**
 * 获取面板视图输入参数
 *
 * @export
 * @return {*}
 */
export function usePanelViewProps() {
	return {
		...useViewProps(),
	};
}

/**
 * 获取面板视图基础
 *
 * @export
 * @param {IPanelViewModel} model 面板视图模型
 * @param {IParam} props 输入参数
 * @return {*}
 */
export function usePanelViewBasic(model: IPanelViewModel, props: IParam) {
	const getClassNames = (props: IParam) => {
		return getViewClassNames(model, props);
	};
	return {
		...useViewBasic(model, props),
		getClassNames,
	};
}

/**
 * 面板视图行为
 *
 * @export
 */
export function usePanelViewAction(
	controller: IPanelViewController<IPanelViewStore, IPanelViewAbility>
) {
	return {
		...useViewAction(controller),
	};
}

/**
 * 获取面板视图控制器输入参数
 *
 * @export
 * @param {IPanelViewModel} model
 * @param {IParam} props
 * @param {QXEvent<IViewEvent<PanelViewActionType, IPanelViewAbility>>} evt
 * @return {*}  {IPanelViewControllerParams<PanelViewActionType, IPanelViewAbility>}
 */
export function usePanelViewControllerParams(
	model: IPanelViewModel,
	props: IParam,
	evt: QXEvent<IViewEvent<PanelViewActionType, IPanelViewAbility>>
): IPanelViewControllerParams<PanelViewActionType, IPanelViewAbility> {
	return {
		...useViewControllerParams<IPanelViewStore, IPanelViewModel>(
			model,
			props,
			evt
		),
	};
}
